package com.rjwh.dingdong.client.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aishua.lib.utils.AsStrUtils;
import com.rjwh.dingdong.client.R;
import com.rjwh.dingdong.client.bean.localbean.MathBookMenuData;
import com.rjwh.dingdong.client.util.ViewHolder;


/**
 * @author Kay
 * @ClassName MathGamePopListAdapter
 * @Description
 * @date 2016-8-25
 * @history 2016-8-25 author: description:
 */
public class MathGamePopListAdapter extends AdapterBase<MathBookMenuData> {

    private Context context;

    public MathGamePopListAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected View getExView(int position, View convertView, ViewGroup parent) throws Exception {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.math_game_pop_list_item_layout, null);
        }
        TextView nameTv = ViewHolder.get(convertView, R.id.math_game_pop_list_item_name);
        TextView descTv = ViewHolder.get(convertView, R.id.math_game_pop_list_item_desc);
        MathBookMenuData mathBookMenuData = getList().get(position);
        if (mathBookMenuData == null) {
            return convertView;
        }

        String bookmenuname = mathBookMenuData.getBookmenuname();
        String agestage = mathBookMenuData.getAgestage();

        if (!AsStrUtils.isEmpty(bookmenuname)) {
            nameTv.setText(bookmenuname);
        }

        if (!AsStrUtils.isEmpty(agestage)) {
            descTv.setText("适合"+agestage);
        }
        return convertView;
    }
}
